/**   
 * @Title: BeiDanGetTeamListCommunicater.java 
 * @Package com.esun.rabbit2.communicaters.beijingdanchang 
 * @Description:  获取北单联赛列表通信接口
 * @author: kael gaojian@500wan.com   
 * @date: 2012-4-5 下午15:26:02  
 * Copyright: (C) 2011 Shenzhen E-sun Sky Net Technology Co.,ltd.
 */
package com.esun.rabbit2.communicaters.beijingdanchang;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;

import javax.xml.parsers.ParserConfigurationException;

import org.apache.http.client.ClientProtocolException;
import org.xml.sax.SAXException;

import com.esun.config.BussinessCode;
import com.esun.config.Key;
import com.esun.model.beijingdanchang.BeidanLotteryInfo;
import com.esun.network.ServerCommunicater;
import com.esun.util.HashMapUtil;
import com.esun.util.log.EDebug;

/**
 * @ClassName: BeiDanGetTeamListCommunicater
 * @Description: 获取北单联赛列表通信接口
 * @author: kael gaojian@500wan.com
 * @date: 2012-4-5 下午15:26:02
 * 
 */
public class BeiDanGetTeamListCommunicater extends ServerCommunicater {
	private boolean isSucceed = false;

	public boolean isGetTeamListSucceed() throws ClientProtocolException, IOException, ParserConfigurationException, SAXException {
		ArrayList<HashMap<String, String>> arraylist = new ArrayList<HashMap<String, String>>();
		arraylist.add(HashMapUtil.getMapItem(BussinessCode.PASER_MID, BussinessCode.MID_BEIDAN_GETTEAMLIST));// 接口号
		super.getServerResponse(arraylist, true);
		if (super.getState() == 100) {
			isSucceed = true;
		} else {
			isSucceed = false;
		}
		return isSucceed;
	}

	/**
	 * @Title: updateTeamInfo
	 * @Description:联赛列表信息
	 * @param: 设定文件
	 * @return: void 返回类型
	 * @throws
	 */
	public void updateTeamInfo() {
		BeidanLotteryInfo.getBeiDanLotteryInfo().getSimpleLeagueList().clear();
		try {
			String divder = "\\|";
			String[] strResults = (super.getResult().get(Key.KEY_TEAM)).split(divder);
			String[] strImageId = (super.getResult().get(Key.KEY_IMAGEID)).split(divder);
			for (int i = 0; i < strResults.length; i++) {
				Hashtable<String, Object> hashtable = new Hashtable<String, Object>();
				hashtable.put(Key.KEY_IS_CHECKED, true);
				hashtable.put(Key.KEY_SAISHI_NAME, strResults[i]);
				hashtable.put(Key.KEY_IMAGE_ID, strImageId[i]);
				BeidanLotteryInfo.getBeiDanLotteryInfo().getSimpleLeagueList().add(hashtable);
				EDebug.o(this, strResults[i] + strImageId[i]);
			}
		} catch (Exception e) {
			EDebug.o(this, "返回数据错误");
		}
		EDebug.o(this, "the list size is =" + BeidanLotteryInfo.getBeiDanLotteryInfo().getSimpleLeagueList().size());
	}
}
